package com.grm.controller;

import com.alibaba.fastjson.JSON;
import com.grm.common.Result;
import com.grm.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "用户管理接口", description = "操作用户")
@RestController
public class UserController {
    @Operation(summary = "添加用户", description = "添加用户")
    @PostMapping("/add")
    public Result add(@RequestBody User user) {
        log.info("user={}", JSON.toJSONString(user));
        return Result.success("添加成功！");
    }

    @Operation(summary = "查询用户列表", description = "查询用户列表")
    @Parameters({
            @Parameter(name = "username", description = "名字"),
            @Parameter(name = "phone", description = "手机号")
    })
    @GetMapping("/get/users")
    public Result queryUsers(@RequestParam(required = false) String username,
                             @RequestParam(required = false) String phone) {
        log.info("username={},phone={}", username,phone);
        return Result.success("查询成功！");
    }
}
